package com.dgut.service.serviceImpl;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.dgut.common.SelectRole;
import com.dgut.mapper.ProcessVoucherMapper;
import com.dgut.pojo.ProcessVoucher;
import com.dgut.service.ProcessVoucherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class ProcessVoucherServiceImpl implements ProcessVoucherService {
    @Resource
    private ProcessVoucherMapper processVoucherMapper;


    /**
     * start-zwb
     */
    /**
     * end-zwb
     */


    /**
     * start-gxd
     */
    /**
     * end-gxd
     */


    /**
     * start-lzh
     */
    @Override
    @SaCheckLogin
    @SaCheckRole(SelectRole.ADMIN)
    public Object selectProcessVoucherByOrderId(Integer orderId){
        ConcurrentHashMap resultMap = new ConcurrentHashMap();
        ProcessVoucher processVoucher = processVoucherMapper.selectProcessVoucherByOrderId(orderId);
        resultMap.put("processVoucher",processVoucher);
        return resultMap;
    }

    @Override
    public void deleteByOrderId(int orderId) {
        Map map = new HashMap();
        map.put("order_id",orderId);
        processVoucherMapper.deleteByMap(map);
    }
    /**
     * end-lzh
     */

    /**
     * start-hwf
     */

    @Override
    public void insertProcessVoucher(int orderId, String url) {
        ProcessVoucher processVoucher = new ProcessVoucher();
        processVoucher.setProcessVoucher(url);
        processVoucher.setOrderId(orderId);
        processVoucherMapper.insert(processVoucher);

    }
    /**
     * end-hwf
     */
}
